package com.atguigu.gmall.user.service.impl;

import com.atguigu.gmall.common.util.UserAuthUtils;
import com.atguigu.gmall.user.vo.UserAuthInfoVo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.gmall.user.entity.UserAddress;
import com.atguigu.gmall.user.service.UserAddressService;
import com.atguigu.gmall.user.mapper.UserAddressMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lfy
 * @description 针对表【user_address(用户地址表)】的数据库操作Service实现
 * @createDate 2022-10-14 09:31:11
 */
@Service
public class UserAddressServiceImpl extends ServiceImpl<UserAddressMapper, UserAddress>
        implements UserAddressService {


    @Autowired
    UserAddressMapper userAddressMapper;

    @Override
    public List<UserAddress> getUserAddressByUserId() {
        UserAuthInfoVo info = UserAuthUtils.getUserAuthInfo();
        Long userId = info.getUserId();


        List<UserAddress> addresses = userAddressMapper.selectList(new LambdaQueryWrapper<UserAddress>()
                .eq(UserAddress::getUserId, userId));
        return addresses;
    }
}




